﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using com.ClickCricket.bll;

public partial class Controls_CountryUserControl : System.Web.UI.UserControl
{

    protected void Page_Load(object sender, EventArgs e)
    {
        string path = Server.MapPath("Home.aspx");
        try
        {
            int cID = Convert.ToInt16(Request.Params.Get(0));
            GetCountryInfo(cID);
        }
        catch
        {
            Server.Transfer("Home.aspx");
        }

    }

    private void GetCountryInfo(int cID)
    {
        com.ClickCricket.bll.Country country = CountryService.Instance.getCountry(cID);
        cImage.ImageUrl = country.CountryImage;
        cName.Text = country.CountryName;

        List<com.ClickCricket.bll.Series> _seriesList = SeriesService.Instance.getOnGoingSeriesByCountry(cID);
        this.Controls.Add(new LiteralControl("<br />"));
        this.Controls.Add(new LiteralControl("<h2><u>On Going series</u></h2>"));
        for (int i = 0; i < _seriesList.Count; i++)
        {
            LinkButton l = new LinkButton();
            l.Text = _seriesList[i].SeriesName;
            l.PostBackUrl = "~/Series.aspx?SeriesID=" + _seriesList[i].SeriesID;
            this.Controls.Add(l);
            this.Controls.Add(new LiteralControl("<br />"));
        }
        if (_seriesList.Count == 0)
        {
            this.Controls.Add(new LiteralControl("No On going series"));
            this.Controls.Add(new LiteralControl("<br />"));
        }


        _seriesList = SeriesService.Instance.getUpComingSeriesByCountry(cID);
        this.Controls.Add(new LiteralControl("<br />"));
        this.Controls.Add(new LiteralControl("<h2><u>Up coming series</u></h2>"));
        for (int i = 0; i < _seriesList.Count; i++)
        {
            LinkButton l = new LinkButton();
            l.Text = _seriesList[i].SeriesName;
            l.PostBackUrl = "~/Series.aspx?SeriesID=" + _seriesList[i].SeriesID;
            this.Controls.Add(l);
            this.Controls.Add(new LiteralControl("<br />"));
        }
        if (_seriesList.Count == 0)
        {
            this.Controls.Add(new LiteralControl("No Up Coming series"));
            this.Controls.Add(new LiteralControl("<br />"));
        }

        _seriesList = SeriesService.Instance.getCompletedByCountry(cID);
        this.Controls.Add(new LiteralControl("<br />"));
        this.Controls.Add(new LiteralControl("<h2><u>Completed series</u></h2>"));
        for (int i = 0; i < _seriesList.Count; i++)
        {
            LinkButton l = new LinkButton();
            l.Text = _seriesList[i].SeriesName;
            l.PostBackUrl = "~/Series.aspx?SeriesID=" + _seriesList[i].SeriesID;
            this.Controls.Add(l);
            this.Controls.Add(new LiteralControl("<br />"));
        }
        if (_seriesList.Count == 0)
        {
            this.Controls.Add(new LiteralControl("No Completed series"));
            this.Controls.Add(new LiteralControl("<br />"));
        }


    }
}
